package com.ssy.lingxi.purchase.repository;

import com.ssy.lingxi.purchase.entity.purchaseinquiry.PurchaseInquiry;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

/**
* 采购询价DB操作类
* @date 2021/1/19
*/
@Repository
public interface PurchaseInquiryRepository extends JpaRepository<PurchaseInquiry, Long>, JpaSpecificationExecutor<PurchaseInquiry> {


    PurchaseInquiry findByPurchaseInquiryNoAndCreateMemberIdAndCreateMemberRoleId(String purchaseInquiryNo,Long memberId,Long memberRoleId);

    PurchaseInquiry findByIdAndCreateMemberIdAndCreateMemberRoleId(Long id,Long memberId,Long memberRoleId);
    PurchaseInquiry findByIdAndMemberIdAndMemberRoleId(Long id,Long memberId,Long memberRoleId);
    PurchaseInquiry findByPurchaseInquiryNoAndMemberIdAndMemberRoleId(String purchaseInquiryNo,Long memberId,Long memberRoleId);


    void deleteAllByIdIn(List<Long> ids);

    PurchaseInquiry findByPurchaseInquiryNo(String purchaseInquiryNo);


    List<PurchaseInquiry> findAllByCreateMemberIdAndCreateMemberRoleIdAndIdIn(Long memberId,Long memberRoleId,List<Long> ids);

    List<PurchaseInquiry> findAllByIdInAndExternalState(Set<Long> ids,Integer external);

    PurchaseInquiry findByIdAndExternalState(Long id,Integer external);

    List<PurchaseInquiry> findByCreateMemberIdAndCreateMemberRoleId(Long memberId, Long roleId);
}
